<html>
    <head>
        <title>Test</title>
        <style></style>
        <script|module>

import * as sys from "@sys";
import * as srt from "@sciter";

document.on("click", "#async", async function() {
   const path = URL.toPath(__DIR__ + "test1.txt");
   console.log(path);

   const file = await sys.fs.open(path, "w+", 0o666)

   const element = document.$("input");

   await file.write(element.value || "test");
   await file.close();
});

document.on("click", "#sync", function() {
   const path = URL.toPath(__DIR__ + "test2.txt");
   console.log(path);

   const file = sys.fs.$open(path, "w+", 0o666);

   const element = document.$("input");

   file.$write( srt.encode(element.value,"utf-8"));
   file.$close();
});


        </script>
    </head>
    <body>

<input|text placeholder="text to write" />
<button#async>write to test.txt, async</button>
<button#sync>write to test.txt, sync</button>

    </body>
</html>